class_name Cell
#操作用的cell
var location:Vector3i
var item:int 
var basis:Basis
var gridmap:GridMap #获取偏移值，还是得有这个数据

# 原Axis已经弃用，而是直接使用Vector3i表示方向——这样不用太多解释就可以六方向，而且还能直接和既有函数配合
#旋转offset计算已经搬到CUBE作为全局可用的计算专用工具类

# 从gridmap获取cell的数据
static func gridmap_construct(location:Vector3i,gridmap:GridMap)->Cell:
	var cell = Cell.new()
	cell.location = location
	cell.item = gridmap.get_cell_item(location)
	cell.basis = gridmap.get_cell_item_basis(location)
	cell.gridmap = gridmap
	return cell

func rotate(center:Vector3, axis:Vector3i):
	var new_offset:Vector3 = (gridmap.map_to_local(location)-center).rotated(axis, PI/2)
	location = gridmap.local_to_map(center + new_offset)
	basis = basis.rotated(axis, PI/2)
	
func apply(gridmap:GridMap):
	gridmap.set_cell_item(location, item, gridmap.get_orthogonal_index_from_basis(basis))
	
